<%@page import="Form.RoomForm"%>
<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>

<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html"%>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic"%>


<!DOCTYPE html>
<html:html lang="true">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title><bean:message key="welcome.title" /></title>
<link
	href="css/mini3537.css?files=reset,common,form,standard,960.gs.fluid,simple-lists,block-lists,planning,table,calendars,wizard,gallery"
	rel="stylesheet" type="text/css">
<link rel="shortcut icon" type="image/x-icon" href="favicon.ico">
<link rel="icon" type="image/png" href="favicon-large.png">
<script type="text/javascript"
	src="js/miniab15.php?files=html5,jquery-1.4.2.min,old-browsers,jquery.accessibleList,searchField,common,standard,jquery.tip,jquery.hashchange,jquery.contextMenu,list"></script>

<link href="datepicker/themes/ui-lightness/jquery.ui.all.css"
	rel="stylesheet" type="text/css">
<script type="text/javascript" src="js/jquery-1.7.1.min.js"></script>
<script type="text/javascript" src="js/jquery.ui.core.js"></script>
<script type="text/javascript" src="js/jquery.ui.datepicker.js"></script>
<script type="text/javascript" src="js/jquery.ui.widget.js"></script>
<html:base />


</head>
<body>
	<%@ include file="/Header.jsp"%>
	<!-- ####################                  Vertical Menu                    ########################## -->
	<%@ include file="/verticalmenu.jsp"%>

	<!-- ####################                  Vertical Menu                    ########################## -->

	<!-- *************************************** Content *************************************************** -->
	<section class="grid_9">
		<div class="block-border">
			<div class="block-content">
				<!-- We could put the menu inside a H1, but to get valid syntax we'll use a wrapper -->
				<div class="h1 with-menu">
					<h1>Web stats</h1>
				</div>

				<div class="block-controls">

					<ul class="controls-tabs js-tabs same-height with-children-tip">
						<li><a href="#tab-stats" title="Charts"><img
								src="images/icons/web-app/24/Bar-Chart.png" width="24"
								height="24"></a></li>
						<li><a href="#tab-comments" title="Comments"><img
								src="images/icons/web-app/24/Comment.png" width="24" height="24"></a></li>
						<li><a href="#tab-medias" title="Medias"><img
								src="images/icons/web-app/24/Picture.png" width="24" height="24"></a></li>
						<li><a href="#tab-users" title="Users"><img
								src="images/icons/web-app/24/Profile.png" width="24" height="24"></a></li>
						<li><a href="#tab-infos" title="Informations"><img
								src="images/icons/web-app/24/Info.png" width="24" height="24"></a></li>
					</ul>

				</div>

				<html:form styleClass="form" action="room.do" styleId="room">

					<fieldset class="grey-bg">
						<legend>
							<a href="#">Options</a>
						</legend>

						<div class="float-left gutter-right">
							<label for="stats-period">Room Name</label> <span
								class="input-type-text"> <html:text name="RoomForm"
									property="name" styleId="nameRoom"></html:text></span>
						</div>
						<div class="float-left gutter-right">
							<label for="stats-period">Flood</label> <span
								class="input-type-text"> <html:text property="floo"
									name="RoomForm" styleId="flooRoom"></html:text></span>
						</div>
						<div class="float-left gutter-right">
							<label for="stats-period">Square</label> <span
								class="input-type-text"> <html:text property="square"
									name="RoomForm" styleId="squareRoom"></html:text></span>
						</div>
						<div class="float-left gutter-right">
							<label for="stats-period">Price</label> <span
								class="input-type-text"> <html:text property="price"
									name="RoomForm" styleId="priceRoom"></html:text></span>
						</div>

						<div class="float-left gutter-right">
							<br> <label for="stats-period">Builts</label>
							<html:select name="RoomForm" property="idBuilt"
								styleId="builtRoom">
								<html:options collection="arrBuilt" property="id"
									labelProperty="name" />
							</html:select>
							<html:hidden property="idBuilt" styleId="idBuilt" />
						</div>
						<div class="float-left gutter-right">

							<br> <label for="stats-period">Status</label>
							<p class="input-height grey-bg">
								<html:radio property="status" value="true" styleId="statusRoom"></html:radio>
								&nbsp;<label for="complex-fr-active-1">Sold</label>
								<html:radio property="status" value="false"
									styleId="statusRoom2"></html:radio>
								&nbsp;<label for="complex-fr-active-0">UnSell</label>
							</p>
						</div>

						<div class="float-left gutter-right">
							<br> <span class="input-type-text"> <label
								for="stats-period">Note</label> <html:textarea property="note"
									styleId="noteRoom" name="RoomForm"
									style="margin-top: 2px; margin-bottom: 2px; height: 67px; margin-left: 2px; margin-right: 2px; width: 674px; " /></span>
						</div>

					</fieldset>


					<ul class="message no-margin">

						<button type="button" class="red" onclick="cancel()">Cancel</button>
						<button type="reset" class="grey">Reset</button>
						<button type="button" onclick="saveRooms()" id="saveRoom">
							<img src="images/icons/fugue/tick-circle.png" width="16"
								height="16"> Save
						</button>
					</ul>
				</html:form>
			</div>
		</div>
	</section>


	<!-- *************************************** Content *************************************************** -->
	</article>
	<!--Footer-->
	<%@ include file="/Footer.jsp"%>
	<!-- Footer -->
</body>
</html:html>
<script language="javascript">

  /*   var idBuilt = document.getElementById("idLand").value ;
    built = document.getElementById("idBuilt"); */
   	
   	function loadForm(){
   		var type = '<%=(String) request.getAttribute("type")%>';
   		    if(type == "detail"){
   		        document.getElementById("nameRoom").disabled=true;
   		        document.getElementById("flooRoom").disabled=true;
   		        document.getElementById("squareRoom").disabled=true;
   		        document.getElementById("priceRoom").disabled=true;
   		        document.getElementById("builtRoom").disabled=true;
   		        document.getElementById("statusRoom").disabled=true; 
   		        document.getElementById("statusRoom2").disabled=true; 
   		        document.getElementById("noteRoom").disabled=true;
   		        document.getElementById("saveRoom").disabled=true    ;   
   		    }
   		//loadBuilt(land,idLand);
   	}   
   	

//--------- load Built -----------------
/* function loadBuilt(built,idBuilt){
	 for(var i=0;i< built.length;i++ )
	 {
	 	if(land.options[i].text == idBuilt)
	 		built.selectedIndex = i;
	 }
}
 */
 function validateData(){
	 
	 if(document.getElementById("flooRoom").value == ''){
			alert('Plesea Insert Flood ');
			return false;
		}		
		if(document.getElementById("squareRoom").value == ''){
			alert('Plesea Insert Square ');
			return false;
		}		
		if(document.getElementById("priceRoom").value == ''){
			alert('Plesea Insert Price');
			return false;
		}
	 
		if(isNaN(document.getElementById("flooRoom").value)){
			alert('Plesea Insert Flood is Number');
			return false;
		}		
		if(isNaN(document.getElementById("squareRoom").value)){
			alert('Plesea Insert Square is Number');
			return false;
		}		
		if(isNaN(document.getElementById("priceRoom").value)){
			alert('Plesea Insert Prive is Number');
			return false;
		}
		
		
		return true;
	}
//--------------------- save or edit --------------------------------


	function saveRooms() {
	    var type = '<%=(String) request.getAttribute("type")%>';
	    id = '<%=(String) request.getAttribute("id")%>';
	    
	    if(validateData() == true){
	    	if (type == 'add') {
				document.getElementById("room").action = 'room.do?method=addRoom&type=add';
				document.getElementById("room").submit();

			} else {
				document.getElementById("room").action = 'room.do?method=editRoom&type=edit&id='+ id;
				document.getElementById("room").submit();
			}
	    	
	    }
		
	}

	// --------------------- chon ngay thang --------------------------------

	function cancel() {
		document.getElementById("room").action = 'room.do?method=getAllRoom';
		document.getElementById("room").submit();
	}
</script>